<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDeclarativeListReference Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDeclarativeListReference Class Reference<br /><sup><sup>[<a href="qtdeclarative.html">QtDeclarative</a> module]</sup></sup></h1><p>The QDeclarativeListReference class allows the manipulation of
<a href="qdeclarativelistproperty.html">QDeclarativeListProperty</a>
properties. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdeclarativelistreference.html#QDeclarativeListReference">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativelistreference.html#QDeclarativeListReference-2">__init__</a></b> (<i>self</i>, QObject, str&#160;<i>property</i>, QDeclarativeEngine&#160;<i>engine</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qdeclarativelistreference.html#QDeclarativeListReference-3">__init__</a></b> (<i>self</i>, QDeclarativeListReference)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#append">append</a></b> (<i>self</i>, QObject)</li><li><div class="fn" />QObject <b><a href="qdeclarativelistreference.html#at">at</a></b> (<i>self</i>, int)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#canAppend">canAppend</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#canAt">canAt</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#canClear">canClear</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#canCount">canCount</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdeclarativelistreference.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativelistreference.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QMetaObject <b><a href="qdeclarativelistreference.html#listElementType">listElementType</a></b> (<i>self</i>)</li><li><div class="fn" />QObject <b><a href="qdeclarativelistreference.html#object">object</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDeclarativeListReference class allows the manipulation of
<a href="qdeclarativelistproperty.html">QDeclarativeListProperty</a>
properties.</p>
<p>QDeclarativeListReference allows C++ programs to read from, and
assign values to a QML list property in a simple and type safe way.
A QDeclarativeListReference can be created by passing an object and
property name or through a <a href="qdeclarativeproperty.html">QDeclarativeProperty</a> instance.
These two are equivalant:</p>
<pre class="cpp">
 <span class="type">QDeclarativeListReference</span> ref1(object<span class="operator">,</span> <span class="string">"children"</span>);

 <span class="type"><a href="qdeclarativeproperty.html">QDeclarativeProperty</a></span> ref2(object<span class="operator">,</span> <span class="string">"children"</span>);
 <span class="type">QDeclarativeListReference</span> ref2 <span class="operator">=</span> qvariant_cast<span class="operator">&lt;</span><span class="type">QDeclarativeListReference</span><span class="operator">&gt;</span>(ref2<span class="operator">.</span>read());
</pre>
<p>Not all QML list properties support all operations. A set of
methods, <a href="qdeclarativelistreference.html#canAppend">canAppend</a>(),
<a href="qdeclarativelistreference.html#canAt">canAt</a>(),
<a href="qdeclarativelistreference.html#canClear">canClear</a>()
and <a href="qdeclarativelistreference.html#canCount">canCount</a>() allow
programs to query whether an operation is supported on a given
property.</p>
<p>QML list properties are typesafe. Only <a href="qobject.html">QObject</a>'s that derive from the correct base
class can be assigned to the list. The <a href="qdeclarativelistreference.html#listElementType">listElementType</a>()
method can be used to query the <a href="qmetaobject.html">QMetaObject</a> of the <a href="qobject.html">QObject</a> type supported. Attempting to add
objects of the incorrect type to a list property will fail.</p>
<p>Like with normal lists, when accessing a list element by index,
it is the callers responsibility to ensure that it does not request
an out of range element using the <a href="qdeclarativelistreference.html#count">count</a>() method before
calling <a href="qdeclarativelistreference.html#at">at</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDeclarativeListReference" />QDeclarativeListReference.__init__ (<i>self</i>)</h3><p>Constructs an invalid instance.</p>


<h3 class="fn"><a name="QDeclarativeListReference-2" />QDeclarativeListReference.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>, str&#160;<i>property</i>, <a href="qdeclarativeengine.html">QDeclarativeEngine</a>&#160;<i>engine</i>&#160;=&#160;None)</h3><p>Constructs a <a href="qdeclarativelistreference.html">QDeclarativeListReference</a> for
<i>object</i>'s <i>property</i>. If <i>property</i> is not a list
property, an invalid <a href="qdeclarativelistreference.html">QDeclarativeListReference</a> is
created. If <i>object</i> is destroyed after the reference is
constructed, it will automatically become invalid. That is, it is
safe to hold <a href="qdeclarativelistreference.html">QDeclarativeListReference</a>
instances even after <i>object</i> is deleted.</p>
<p>Passing <i>engine</i> is required to access some QML created
list properties. If in doubt, and an engine is available, pass
it.</p>


<h3 class="fn"><a name="QDeclarativeListReference-3" />QDeclarativeListReference.__init__ (<i>self</i>, <a href="qdeclarativelistreference.html">QDeclarativeListReference</a>)</h3><h3 class="fn"><a name="append" />bool QDeclarativeListReference.append (<i>self</i>, <a href="qobject.html">QObject</a>)</h3><p>Appends <i>object</i> to the list. Returns true if the operation
succeeded, otherwise false.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#canAppend">canAppend</a>().</p>


<h3 class="fn"><a name="at" /><a href="qobject.html">QObject</a> QDeclarativeListReference.at (<i>self</i>, int)</h3><p>Returns the list element at <i>index</i>, or 0 if the operation
failed.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#canAt">canAt</a>().</p>


<h3 class="fn"><a name="canAppend" />bool QDeclarativeListReference.canAppend (<i>self</i>)</h3><p>Returns true if the list property can be appended to, otherwise
false. Returns false if the reference is invalid.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#append">append</a>().</p>


<h3 class="fn"><a name="canAt" />bool QDeclarativeListReference.canAt (<i>self</i>)</h3><p>Returns true if the list property can queried by index,
otherwise false. Returns false if the reference is invalid.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#at">at</a>().</p>


<h3 class="fn"><a name="canClear" />bool QDeclarativeListReference.canClear (<i>self</i>)</h3><p>Returns true if the list property can be cleared, otherwise
false. Returns false if the reference is invalid.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#clear">clear</a>().</p>


<h3 class="fn"><a name="canCount" />bool QDeclarativeListReference.canCount (<i>self</i>)</h3><p>Returns true if the list property can be queried for its element
count, otherwise false. Returns false if the reference is
invalid.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#count">count</a>().</p>


<h3 class="fn"><a name="clear" />bool QDeclarativeListReference.clear (<i>self</i>)</h3><p>Clears the list. Returns true if the operation succeeded,
otherwise false.</p>
<p><b>See also</b> <a href="qdeclarativelistreference.html#canClear">canClear</a>().</p>


<h3 class="fn"><a name="count" />int QDeclarativeListReference.count (<i>self</i>)</h3><p>Returns the number of objects in the list, or 0 if the operation
failed.</p>


<h3 class="fn"><a name="isValid" />bool QDeclarativeListReference.isValid (<i>self</i>)</h3><p>Returns true if the instance refers to a valid list property,
otherwise false.</p>


<h3 class="fn"><a name="listElementType" /><a href="qmetaobject.html">QMetaObject</a> QDeclarativeListReference.listElementType (<i>self</i>)</h3><p>Returns the <a href="qmetaobject.html">QMetaObject</a> for the
elements stored in the list property. Returns 0 if the reference is
invalid.</p>
<p>The <a href="qmetaobject.html">QMetaObject</a> can be used ahead
of time to determine whether a given instance can be added to a
list.</p>


<h3 class="fn"><a name="object" /><a href="qobject.html">QObject</a> QDeclarativeListReference.object (<i>self</i>)</h3><p>Returns the list property's object. Returns 0 if the reference
is invalid.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>